#ifndef PHYSICSCOMPWIDGET_H
#define PHYSICSCOMPWIDGET_H

#include <QWidget>
#include <QtGui>
#include "aed_physicscomp.h"
#include "physicscondmodel.h"
#include "polygonpointsmodel.h"

class PhysicsCompWidget : public QWidget
{
    Q_OBJECT

    AED_PhysicsComp *m_comp;
    QTableView *m_pointtable;
    QTableView *m_condtable;
    PolygonPointsModel *m_model;
    PhysicsCondModel *m_cmodel;
    QPushButton *addpoint;
    QPushButton *removepoint;
    QLabel *points_l;

    QGroupBox* group;
    QDoubleSpinBox *friction;
    QDoubleSpinBox *restitution;
    QCheckBox *sensor;
    QComboBox *shape;
    QDoubleSpinBox *shape_size_x;
    QDoubleSpinBox *shape_size_y;
    QDoubleSpinBox *linear_damping;
    QDoubleSpinBox *angular_damping;
    QDoubleSpinBox *density;
    QComboBox *type;
    QCheckBox *fixed_rotation;
    QCheckBox *bullet;
    QPushButton *addcond;
    QPushButton *removecond;

public:
    explicit PhysicsCompWidget(AED_PhysicsComp *comp, QWidget *parent = 0);

    void setComp(AED_PhysicsComp *comp);
signals:

public slots:
    void SetEnabled(bool enabled){m_comp->SetEnabled(enabled);}
    void SetFriction(double fric){m_comp->SetFriction(fric);}
    void SetRestitution(double rest){m_comp->SetRestitution(rest);}
    void SetSensor(bool sensor){m_comp->SetSensor(sensor);}
    void SetShape(const QString &shape){
        m_comp->SetShape(shape);
        if(shape=="polygon"){
            m_pointtable->setDisabled(false);
            addpoint->setDisabled(false);
            removepoint->setDisabled(false);
            points_l->setDisabled(false);
        }else{
            m_pointtable->setDisabled(true);
            addpoint->setDisabled(true);
            removepoint->setDisabled(true);
            points_l->setDisabled(true);
        }

        /*if(shape == "circle"){
            shape_size_y->setDisabled(true);
        }else{
            shape_size_y->setDisabled(false);
        }*/
    }
    void SetShapeSizeX(double size){m_comp->SetShapeSizeX(size);}
    void SetShapeSizeY(double size){m_comp->SetShapeSizeY(size);}
    void SetLinearDamping(double damp){m_comp->SetLinearDamping(damp);}
    void SetAngularDamping(double damp){m_comp->SetAngularDamping(damp);}
    void SetType(const QString &type){m_comp->SetType(type);}
    void SetFixedRotation(bool rot){m_comp->SetFixedRotation(rot);}
    void SetBullet(bool bullet){m_comp->SetBullet(bullet);}
    void SetDensity(double density){m_comp->SetDensity(density);}
    void RemovePoint();
    void RemoveCondition();


};

#endif // PHYSICSCOMPWIDGET_H
